package cn.bitkit.tools.common;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @author changbo
 */
public class NumberUtil {

    public static float setScale(float val, int scale){
        return new BigDecimal(val).setScale(scale, RoundingMode.HALF_UP).floatValue();
    }

    public static double setScale(double val, int scale){
        return new BigDecimal(val).setScale(scale, RoundingMode.HALF_UP).doubleValue();
    }

}
